
namespace Jaws.Core.Web.MappedTypes
{
    public class Label : System.Web.UI.WebControls.Label
    {
        bool IsTextNullOrEmpty
        {
            get
            {
                return string.IsNullOrEmpty(Text);
            }
        }

        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            if (IsTextNullOrEmpty) return;
            writer.RenderEndTag();
        }

        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            if (IsTextNullOrEmpty) return;
            if (!string.IsNullOrEmpty(CssClass)) writer.AddAttribute("class", CssClass);
            if (!string.IsNullOrEmpty(AssociatedControlID)) writer.AddAttribute("for", AssociatedControlID);
            if (!string.IsNullOrEmpty(ID)) writer.AddAttribute("id", ClientID);

            writer.RenderBeginTag("label");
            writer.Write(Text);
        }
    }
}